const express =require("express")
const bodyParser=require("body-parser")
const http=require("http")
const proxy=require("http-proxy-middleware")
const path=require("path")
const app=express()
app.use(express.static(path.join(__dirname,"public")))
app.use(bodyParser.json())
// app.use("/v1/restserver/ting",proxy({target:"http://tingapi.ting.baidu.com",changeOrigin:true}))
app.get("/v1/restserver/ting",function(req,res){
    console.log(req.originalUrl)
   var request=http.get("http://tingapi.ting.baidu.com"+req.originalUrl,function(response){
     let body=""
     response.on("data",function(data){
        body += data
     })
     response.on("end",function(data){
         res.send(body)
     })
   })
})
app.listen(3000)
